Opal.Request = function opal_ajax_request(o) {
	this.url = o.url;
	this.onComplete = o.onComplete;
	if (typeof o.params != 'undefined') {
		this._params = o.params;
	} else {
    this._params = [];
  }
  if (typeof o.method != 'undefined') {
		this.method = o.method;
	} else {
    this.method = 'post';
  }
}
Opal.Request.prototype = {
	submit: function() {
		var obj = this;
		new Ajax.Request(obj.url, {
			method: obj.method,
			parameters: this._params.join('&'),
			onComplete: obj.onCompleteHandler.bind(obj)
		});
	},
	addSimple: function(name, value) {
		value = (typeof value != 'undefined' && value != null) ? value.toString() : '';
		this._params[name] = value;	
	},
	onCompleteHandler: function(originalRequest) {
		var obj = this;
		var datas = eval('(' + originalRequest.responseText + ')');
		obj.onComplete(datas);
	}
}
